import request from '@/utils/http'

const PATH = '/tweets'

const COMMENTS_PATH = '/tweet-comments'

const LIKE_PATH = '/tweet-praises'

export function getFeedsList(params: any) {
	return request({ url: PATH, method: 'get', params })
}

export function getFeedsListFilter(data: any) {
	return request({ url: '/tweets-filter', method: 'post', data })
}

export function addFeeds(data: any) {
	return request({ url: PATH, method: 'post', data })
}

export function updateFeeds(data: any) {
	return request({ url: '/orderno-tweets/' + data.orderNo, method: 'put', data })
}

export function setFeedsHide(data: any) {
	return request({ url: PATH + '/' + data.id + '/hide', method: 'put', data })
}

export function removeFeeds(id: string) {
	return request({ url: PATH + '/' + id, method: 'delete' })
}

export function getFeedsDetail(params: any) {
	return request({ url: PATH + '/' + params.tweetId, method: 'get', params })
}

export function getCommentList(params: any) {
	const { tweetId } = params
	return request({
		url: PATH + '/' + tweetId + '/comments',
		method: 'get',
		params
	})
}

export function addComment(data: any) {
	return request({ url: COMMENTS_PATH, method: 'post', data })
}

export function removeComment(id: string) {
	return request({ url: COMMENTS_PATH + '/' + id, method: 'delete' })
}

export function getCommentDetail(id: string) {
	return request({ url: COMMENTS_PATH + '/' + id, method: 'get' })
}

export function likeFeeds(tweetId: string) {
	return request({ url: LIKE_PATH, method: 'post', data: { tweetId } })
}

export function unlikeFeeds(tweetId: string) {
	return request({ url: LIKE_PATH + '/' + tweetId, method: 'delete' })
}

export function getMyFeedsList(params: any) {
	return request({ url: '/base-tweets', method: 'get', params })
}

export function getFollowFeedsList(params: any) {
	return request({ url: '/follow-tweets', method: 'get', params })
}

export function getEventFeedsList(params: any) {
	const { eventId } = params
	return request({
		url: '/events/' + eventId + '/tweets',
		method: 'get',
		params
	})
}

export function getUserFeedsList(params: any) {
	const { userId } = params
	return request({ url: `/users/${userId}/tweets`, method: 'get', params })
}

export function getFeedsByOrderNo(params: any) {
	return request({ url: '/orderno/tweet', method: 'get', params })
}

export function translateFeeds(params: any) {
	return request({
		url: PATH + '/' + params.id + '/translate',
		method: 'get',
		params
	})
}

export function getFeedsFilterConfig(params: any) {
	return request({
		url: '/tweets-filter-getdefault',
		method: 'get',
		params
	})
}
